package com.lby.redisdemo.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * @ClassName RedisMessageListener
 * @Description TODO
 * @Author louby0923
 * @Date 2023/3/31 13:52
 * @Version 1.0
 */
@Component
@Slf4j
public class RedisMessageListener implements MessageListener {
    /**
     * 监听redis是否有消息推送过来
     *
     * @param message
     * @param pattern
     */
    @Override
    public void onMessage(Message message, byte[] pattern) {
        System.out.println("订阅频道:"+new String(message.getChannel()));
        log.info(new String(pattern));
        log.info(message.toString());
    }
}
